package com.elead.oa.controller;

import com.elead.oa.common.PageObject;
import com.elead.oa.entity.Attendance;
import com.elead.oa.service.attendance.IAttendanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 考勤管理
 * AttendanceController
 * 创建人:xiaozuolin
 * 创建时间：2021年09月28日 14:21:07
 *
 * @version 1.0.0
 */
@RestController
@RequestMapping("/attendance")
@Slf4j
@CrossOrigin
@Api(tags = "考勤控制层")
public class AttendanceController {

    @Autowired
    private IAttendanceService attendanceService;

    @GetMapping("/find_attendance_by_employee_id/{id}")
    @ApiOperation(value = "根据员工id查询考勤表",httpMethod = "GET",produces = "application/json",notes = "根据员工id查询考勤表")
    public PageObject<Attendance> findAttendanceByEmployeeId(@PathVariable("id") int id) {
        PageObject<Attendance> pageObject = new PageObject<>();
        pageObject.setRecords(attendanceService.getAttendanceByEmployeeId(id));
        return pageObject;
    }


    /**
     * 考勤管理 列表页面
     *
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询考勤表所有信息",httpMethod = "GET",produces = "application/json",notes = "查询考勤表所有信息")
    public PageObject<Attendance> list() {
        PageObject<Attendance> pageObject = new PageObject<>();
        pageObject.setRecords(attendanceService.list());
        return pageObject;
    }
}
